package com.springboot.killingsystem.rabbitmq;

import com.springboot.killingsystem.redis.RedisService;
import com.springboot.killingsystem.util.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MQSender {


    @Autowired
    AmqpTemplate amqpTemplate;

    public void secondKillingMessage(SecondKillingMessage message) {
        String msg = RedisService.beanToString(message);
        log.info("send message:"+msg);
        amqpTemplate.convertAndSend(Constant.SECOND_KILLING_QUEUE, msg);
    }
}
